package com.mai4j.maiadmin.model.http;

import com.mai4j.maiadmin.validation.constraints.LanguageTag;
import com.mai4j.maiadmin.validation.constraints.Option;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Positive;
import javax.validation.constraints.Size;
import java.util.Map;

/**
 * 微信公众号请关注: 开源螺丝钉
 * <br>
 * 码云请关注: <a href="https://gitee.com/xiyoufang">https://gitee.com/xiyoufang</a>
 * <br>
 * 哔哩哔哩请关注: <a href="https://space.bilibili.com/438927834">https://space.bilibili.com/438927834</a>
 *
 * @author xiyoufang
 */
@Setter
@Getter
@Accessors(chain = true)
public class SettingSaveReq {

    @Setter
    @Getter
    @Accessors(chain = true)
    public static class Language {
        @NotNull
        @LanguageTag
        private String catalog;
        @NotNull
        @LanguageTag
        private String admin;
    }

    @Setter
    @Getter
    @Accessors(chain = true)
    public static class Mail {
        @NotNull
        @Option(options = {"mail", "smtp"})
        private String engine;
        @NotNull
        @Option(options = {"true", "false"})
        private String ssl;
        @NotNull
        private String hostname;
        @NotNull
        @Email
        private String username;
        @NotNull
        private String personal;
        @NotNull
        private String password;
        @NotNull
        @Positive
        private String port;
        @NotNull
        @Positive
        private String timeout;
    }

    /**
     * siteTitle
     */
    @NotNull
    @Size(min = 1)
    private Map<@LanguageTag String, @Length(min = 3, max = 128) String> siteTitle;
    /**
     * metaTitle
     */
    @NotNull
    @Size(min = 1)
    private Map<@LanguageTag String, @Length(min = 3, max = 512) String> metaTitle;
    /**
     * metaDescription
     */
    @NotNull
    @Size(min = 1)
    private Map<@LanguageTag String, @Length(max = 512) String> metaDescription;
    /**
     * metaKeyword
     */
    @NotNull
    @Size(min = 1)
    private Map<@LanguageTag String, @Length(max = 512) String> metaKeyword;
    /**
     * currency
     */
    @NotNull
    private String currency;
    /**
     * Language
     */
    @Valid
    @NotNull
    private Language language;
    /**
     * Mail
     */
    @Valid
    @NotNull
    private Mail mail;
    /**
     * maintenance
     */
    @NotNull
    @Option(options = {"true", "false"})
    private String maintenance;
    /**
     * 密钥
     */
    @NotNull
    @Length(min = 64, max = 512)
    private String encryption;
}
